package com.yeyouluo.zk;

public class DisLockTest {

    public static void main(String[] args) {
        //10个线程模拟分布式环境
        for (int i = 0; i < 10; i++) {
            new Thread(new DisLockRunnable()).start();//����
        }
    }

    static class DisLockRunnable implements Runnable {

        @Override
        public void run() {
            final DisClient client = new DisClient();
            client.getDisLock();

            // 获取锁后的动作
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            // 释放锁
            client.deleteLock();
        }
    }
}
